package com.blr.controller;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: HelloController
 * Description:
 * Date: 2022/11/17 AM 11:25:33
 * <p>
 * project: codes
 * package: com.blr.controller
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
@RestController
public class HelloController {

    @RequestMapping("/hello")
    public DefaultOAuth2User hello() {
        System.out.println("hello");
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return ((DefaultOAuth2User) authentication.getPrincipal());
    }
}
